package operation;

import student.Student;
import student.StudentArray;

import java.util.Scanner;

public class ModifyOperation implements IOperation{
    @Override
    public void work(StudentArray stulist) {
        System.out.println("修改消息");
        System.out.println("请输入想要修改学生消息的学号:->");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        int sz = stulist.getUsedSize();
        int i = 0;
        for(; i < sz; i++){
            Student stu = stulist.getStudent(i);
            if(id == stu.getStudentId()){
                System.out.println("学习表有该学生");
                System.out.println("请输入修改的姓名");
                String name = sc.next();
                System.out.println("请输入修改的性别");
                String sex = sc.next();
                System.out.println("请输入修改的身份证");
                String Id = sc.next();
                System.out.println("请输入修改的电话");
                String tele = sc.next();
                System.out.println("请输入修改的年龄");
                int age = sc.nextInt();
                Student stu1 = new Student(id,name,age,sex,Id,tele);
                stulist.setStudent(i,stu1);
                System.out.println("修改成功");
                return;
            }
        }
        if (sz == i){
            System.out.println("学生表中无该学生，无法进行修改");
        }
    }
}
